<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">短剧推广</a>
            <a><cite>短剧收费配置</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">选择短剧：</label>
                    <div id="pMenu" style="width:100%;flex:1"></div>
                </div>

                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="video" lay-filter="video"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        {{#  
            if(is_distributor !== 1 && is_branch_office_manage!==1){
                return `
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
                </div>`
            }
        }}
    </script>
    <script type="text/html" id="tbBar">
        
        {{#  
            if(is_distributor !== 1 && is_branch_office_manage!==1){
                return `
                <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>`
            }else{
                return `
                <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                `
            }
        }}
    </script>
    <script>
        let params = {
            elem: '#video'
            , toolbar: '#toolbarDemo'
            , url: '/cps/video/configList' //数据接口
            , id: 'video'
            , page:true
            , limit:15
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 80, sort: true, align:'center' }
                , { field: 'name', title: '名称', width: 160, align:'center' }
                , { field: 'responsibility_person', title: '负责人', align:'center'}
                , { field: 'video_name', title: '短剧名称',  align:'center'}
                , { field: 'sort', title: '开始收费剧集数',  align:'center'}
                , { field: 'pay_amount', title: '每集收费K币',  align:'center'}
                , {
                    field: 'created_at', title: '添加时间', width:200, align:'center', templet: function (d) {
                        return dayjsFormat(d.created_at)
                    }
                }
                , { title: '状态', align:'center', templet: function (d) {
                        return d.status == 1 ? '失效' : '正常'
                    }
                }
                , { toolbar: '#tbBar', title: '操作', width: 150, align:'center'}
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(video)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加', './configInfo.html', 650, 500);
                }
            });
            table.on('tool(video)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    DeleteAjax('/cps/video/deleteConfig',{ id: obj.data.id },'video')
                } else if (event === 'edit') {
                    x_admin_show('编辑', `./configInfo.html?id=${obj.data.id}`, 650, 500);
                }
            });

        });
        
        let selectParams = {
            url: '/cps/video/select',
            selected: [],
            tips: '选择短剧',
            name: 'video_id',
            field_id: 'id',
            field_Name: 'name',
            elem: '#pMenu'
        }
        selectN(selectParams)
    </script>
</body>

</html>